home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Net / Utilities / Seer family 2.0 / seer_common / sc_sk_misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-11-17  |  4.2 KB  |  150 lines  |  [TEXT/KAHL]

  1. /*
  2.     sc_sk_misc.c - general scope window routines
  3. */
  4. #include <EventMgr.h>
  5. #include "sc.h"
  6. #include "sc_filter.h"
  7. #include "sc_scope_window.h"
  8.  
  9. #define CHAN_HEIGHT 24    /* pixels between channels*/
  10. #define MAX_CHAN_VALUE (CHAN_HEIGHT-1)
  11.  
  12. void e_sk_activate()
  13. {
  14. }
  15.  
  16. void e_sk_deactivate()
  17. {
  18. }
  19.  
  20. /* clip_normal - set a windows clipping to the default, full window clip
  21. */
  22. void clip_normal(WindowPtr);
  23. void clip_normal(a_win)
  24. WindowPtr a_win;
  25. {RectRgn(a_win->clipRgn,&a_win->portRect);
  26. }
  27.  
  28. /*
  29.     show_grow - draw the grow icon for only having a vertical
  30.     scroll bar 
  31. */
  32. void show_grow()
  33. {Rect clip_rect;
  34.  clip_rect=CUR_WINDOW->portRect;
  35.  clip_rect.left=clip_rect.right - SCROLL_BAR_PIXLS + 1;
  36.  RectRgn(CUR_WINDOW->clipRgn,&clip_rect);
  37.  DrawGrowIcon(CUR_WINDOW);
  38.  clip_normal(CUR_WINDOW);
  39. }
  40.  
  41. void e_scope_update_event()
  42. {register int i;
  43.  cnt_tab_ent *cur_cnt;
  44.  show_grow();
  45.  MoveTo(gl.cur_windef->char_left_inset,CHAN_HEIGHT);
  46.  for(i=0;i<NUM_SCOPE_CHANS;i++) {
  47.     cur_cnt= SK_wdf->chans[i].sc_counter;
  48.     if(cur_cnt==NIL)
  49.         break;
  50.     DrawString(RES_pstr(cur_cnt->filname));
  51.      MoveTo(gl.cur_windef->char_left_inset,
  52.            CUR_WINDOW->pnLoc.v+CHAN_HEIGHT);
  53.     }
  54. }
  55.  
  56. void e_scope_grow(where)
  57. Point where;
  58. {Rect r;
  59.  union {
  60.     long grow_as_long;
  61.      Point grow_to;
  62.      } grow_result;
  63.  /* say how big/small a packet window can be*/
  64.  /*quickdraw vars aren't around for a da to get screen bits*/
  65.  SetRect(&r,70,70,CUR_WINDOW->portBits.bounds.right,CUR_WINDOW->portBits.bounds.bottom);
  66.  grow_result.grow_as_long=
  67.       GrowWindow(CUR_WINDOW,where,&r); /* see how big to make it*/
  68.  
  69.  
  70.  r=CUR_WINDOW->portRect;        /*invalidate the old scroll areas*/
  71.  r.left=r.right-SCROLL_BAR_PIXLS+1;
  72.  InvalRect(&r);
  73.  SizeWindow(CUR_WINDOW,
  74.      grow_result.grow_to.h,
  75.      grow_result.grow_to.v,TRUE); /*grow it, update update region*/
  76.  RectRgn(CUR_WINDOW->clipRgn,&CUR_WINDOW->portRect);
  77.  
  78.  r=CUR_WINDOW->portRect;        /*invalidate the new scroll areas*/
  79.  r.left=r.right-SCROLL_BAR_PIXLS+1;
  80.  InvalRect(&r);
  81.  
  82.  SK_wdf->skw_endx=(CUR_WINDOW->portRect.right-SCROLL_BAR_PIXLS);
  83. }
  84.  
  85. void e_scope_down_content(the_event)
  86. EventRecord *the_event;
  87. {Point down_at;            /*where the mouse went down*/
  88.  down_at=the_event->where; /*say where mouse went down*/
  89.  GlobalToLocal(&down_at); /*find control likes local coordinates*/
  90.  /* if down where the grow area would be, pretend it we should
  91.       grow.  DA windows can't grow normaly so we check down in grow here
  92.       Probably should also check active
  93.  */
  94.  if((down_at.h>(CUR_WINDOW->portRect.right-SCROLL_BAR_PIXLS))&&
  95.     (down_at.v>(CUR_WINDOW->portRect.bottom-SCROLL_BAR_PIXLS)))
  96.      e_scope_grow(the_event->where);
  97. }
  98.  
  99. #define CHAN_LEFT 60 /* left edge of display*/
  100. static int scope_x_pos=CHAN_LEFT;
  101. /*
  102.     one tick happened, draw the updated counters
  103. */
  104. void scope_tick()
  105. {register int i;
  106.  register scope_rec *scan_rec;
  107.  register int channel_value;
  108.  cnt_tab_ent *cur_cnt;
  109.  WindowPtr save_window;                /*the graf port before the update*/
  110.  windef *save_windef;                /*pointer to our per window information*/
  111.  
  112.  if(gl.wdf_scope==NIL)                /*have a scope window?*/
  113.      return;                            /*no, nothing to draw then*/
  114.  GetPort(&save_window);
  115.  save_windef=gl.cur_windef;            /*change the windef with the port*/
  116.  gl.cur_windef= gl.wdf_scope;
  117.  SetPort(CUR_WINDOW);               /*switch to the port to update*/
  118.  
  119.  scan_rec = SK_wdf->chans;             /* scan each channel */
  120.  scope_x_pos++;        /*paint in the next x position*/
  121.  if(scope_x_pos>= SK_wdf->skw_endx)
  122.    scope_x_pos = CHAN_LEFT;
  123.  /*erase the current position*/
  124.  {register int ahead_x;
  125.   PenMode(notPatCopy);
  126.   ahead_x = scope_x_pos + 8;
  127.   if(ahead_x>= SK_wdf->skw_endx)
  128.    ahead_x -= SK_wdf->skw_endx-CHAN_LEFT;
  129.   MoveTo(ahead_x,CUR_WINDOW->portRect.top);
  130.   LineTo(ahead_x,CUR_WINDOW->portRect.bottom);
  131.   PenNormal();
  132.  } /* end register ahead_x */
  133.  for(i=1;i<=NUM_SCOPE_CHANS;i++) {
  134.     cur_cnt=scan_rec->sc_counter;    /* pointer to the current counter */
  135.     if(cur_cnt==NIL)                /* stop when out of counters */
  136.         break;
  137.     channel_value=(cur_cnt->count-scan_rec->sc_value);
  138.     channel_value=max(0,channel_value);
  139.     channel_value=min(MAX_CHAN_VALUE,channel_value);
  140.     scan_rec->sc_value=cur_cnt->count;
  141.      MoveTo(scope_x_pos,CHAN_HEIGHT*i-channel_value-
  142.              gl.cur_windef->char_descent);
  143.      Line(0,0);
  144.      scan_rec++;        /*step to the next channel*/
  145.      }
  146.  
  147.  SetPort(save_window);
  148.  gl.cur_windef=save_windef;
  149. }
  150.